package model;

import java.util.ArrayList;
import java.util.List;

import common.MCore;
import common.MElement;

import expression.MClassAttLowerBound;
import expression.MClassAttUpperBound;

public class MClassAttribute extends MElement {
	private String name;
	private List<MClassAttLowerBound> lowerBounds;
	private List<MClassAttUpperBound> upperBounds;

	public MClassAttribute(MCore c, String n) {
		super(c);
		name = n;
		lowerBounds = new ArrayList<MClassAttLowerBound>();
		upperBounds = new ArrayList<MClassAttUpperBound>();
	}
	
	public String getName() {
		return name;
	}
	
	public MClassAttLowerBound getLowerBound() {
		return lowerBound;
	}
	
	public MClassAttUpperBound getUpperBound() {
		return upperBound;
	}
	
	public List<MClassAttClassVar> getVariables() {
		return variables;
	}
	
	public void init() {
		variables = new ArrayList<MClassAttClassVar>();
		for (MClass c: getCore().getClasses()) {
			MClassAttClassVar v = new MClassAttClassVar(this, c);
			variables.add(v);
		}
	}
	
	public MClassAttClassVar getClassVariable(MClass c) {
		for (MClassAttClassVar v: variables) {
			if (v.getMClass() == c)
				return v;
		}
		return null;
	}
	
	public String toText() {
		return name;
	}	
}
